package net.huashitong.interview.service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.service.SysTableService;
import net.huashitong.interview.dao.EnterpriseFuWuDao;
import net.huashitong.interview.entity.EnterpriseFuWu;
import net.huashitong.interview.entity.InterviewRegister;
import net.huashitong.interview.filter.EnterpriseFuWuFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class EnterpriseFuWuService extends StringPKService<EnterpriseFuWu> {
    @Autowired
    private EnterpriseFuWuDao dao;
    @Autowired
    private SysTableService tableService;


    @Override
    protected BaseDao<EnterpriseFuWu, String> getDao() {
        return dao;
    }

    @Override
    protected void beforeSave(EnterpriseFuWu obj) {
        obj.setSysId(tableService.updateMaxSysId("t_gis_interviewEnterpriseService", null));
    }

    public List<EnterpriseFuWu> queryFuWu(EnterpriseFuWuFilter filter){
        List<EnterpriseFuWu> list = dao.queryFuWu(filter);
        return list;
    }

    public List<Map<String, Object>> baseResult(List<EnterpriseFuWu> list){
        List<Map<String, Object>> result = new ArrayList<>();
        for(EnterpriseFuWu enterpriseFuWu : list){
            Map<String,Object> map = new HashMap<>();
            map.put("sysId",enterpriseFuWu.getSysId());
            map.put("helpEnterprise",enterpriseFuWu.getHelpEnterprise());
            map.put("specificProblem",enterpriseFuWu.getSpecificProblem());
            map.put("fillDate",enterpriseFuWu.getFillDate());
            map.put("state",enterpriseFuWu.getState());
            result.add(map);
        }
        return result;
    }

    public String getNewFillDate(){
        return dao.getNewFillDate();
    }

}
